home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / ARexxTools / Haiku2.lha / Haiku.rexx
Encoding:
OS/2 REXX Batch file  |  1995-05-06  |  4.2 KB  |  146 lines

  1. /****** Haiku.rexx *************************************************
  2. *
  3. *    $VER: Haiku 2.0 (6.5.95) ยท Generates pseudo-random Haiku poems
  4. *
  5. ********************************************************************/
  6.  
  7. call InitVocab()
  8. call random(,,time('s'))
  9. say  GenHaiku()
  10. exit 0
  11.  
  12. GenHaiku:
  13. t = random(1,num_templates)
  14. parse var tem.t line.1 '+' line.2 '+' line.3
  15. out. = ''
  16. do i = 1 to 3
  17.     do while length(line.i)>0
  18.         parse var line.i cmd 3 qual 4 line.i
  19.         c = left(cmd,1)
  20.         ucmd = upper(cmd)
  21.         if v.ucmd ~= "" then
  22.         do
  23.             w = word(v.ucmd,random(1,words(v.ucmd)))
  24.             if datatype(c,'u') then
  25.             w = upper(left(w,1)) || substr(w,2)
  26.             upper c
  27.             if c = 'V' & qual = '@' then
  28.             w = add_ing(w)
  29.             else if c = 'N' & qual = 's' then
  30.             w = pluralize(w)
  31.             else
  32.             line.i = qual || line.i
  33.         end
  34.         else if c = '/' then
  35.         do
  36.             parse value cmd || qual || line.i with '/' list '/' line.i
  37.             w = word(list,random(1,words(list)))
  38.         end
  39.         else
  40.         parse value cmd || qual || line.i with w 2 line.i
  41.         out.i = out.i || w
  42.     end
  43. end
  44. return translate(out.1 || '0a'x || out.2 || '0a'x || out.3 || '0a'x,' ','_')
  45.  
  46. add_ing: procedure
  47. exc. = 0
  48. exc.whisper = 1
  49. exc.wander = 1
  50. exc.flutter = 1
  51. exc.wither = 1
  52. exc.wonder = 1
  53. exv = upper(arg(1))
  54. parse value arg(1) with 100-3 l3+1 l2+1 l1
  55. if index("mbgprndlt",l1) > 0 & index("aeiou",l2) > 0 & index("aeiou",l3) = 0 then
  56. do
  57.     if ~exc.exv then
  58.     w = arg(1) || l1
  59.     else
  60.     w = arg(1)
  61. end
  62. else if l1 = 'e' then
  63. w = left(arg(1),length(arg(1))-1)
  64. else
  65. w = arg(1)
  66. return w || 'ing'
  67.  
  68. pluralize: procedure expose v.
  69. exc. = 0
  70. exc.rose = 1
  71. exc.breeze = 1
  72. exc.branch = 1
  73. exc.beach = 1
  74. exc.glance = 1
  75. exc.thrush = 1
  76. exc.child = 1
  77. exc.fox = 1
  78. exc.moss = 1
  79. exc.sunrise = 2
  80. exc.lotus = 2
  81. exc.gecko = 10
  82. exc.cry = 11
  83. w = arg(1)
  84. uw = upper(w)
  85. do while exc.uw > 0 & exc.uw < 10
  86.     list = value('v.n'exc.uw)
  87.     w = word(list,random(1,words(list)))
  88.     uw = upper(w)
  89. end
  90. if datatype(left(arg(1),1),'u') then
  91. w = upper(left(w,1))substr(w,2)
  92. select
  93.     when exc.uw = 0 then w = w || 's'
  94.     when exc.uw = 10 then w = w || 'es'
  95.     when exc.uw = 11 then w = left(w,2) || 'es'
  96.     otherwise
  97.     call inform("Invalid pluralize exception" exc.uw)
  98.     exit
  99. end
  100. return w
  101.  
  102. InitVocab:
  103. v. = ""
  104. v.a1 = "quick wild small hot white green blue pink thin old light dark"
  105. v.a1 = v.a1 "sad deep lost free far slow sharp blunt hard soft damp dry"
  106. v.a1 = v.a1 "bare tight loose low cold clean proud swift gnarled flat"
  107. v.a1 = v.a1 "strong weak young dull ill"
  108. v.a2 = "open lofty empty eager even weary leaden fallen dismal serene"
  109. v.a2 = v.a2 "languid potent silver awkward shallow pliant simple wrinkled"
  110. v.a2 = v.a2 "falling waiting sighing smiling dreaming sleeping dying"
  111. v.a2 = v.a2 "almond jasmine mournful leaping supple"
  112. v.n1 = "oak tree grove stream brook hill branch rose leaf breeze pool"
  113. v.n1 = v.n1 "root thrush song moon cry glance flame child fox lamb shell"
  114. v.n1 = v.n1 "moss cave cliff rock beach shore wave sea hand path bark fern"
  115. v.n2 = "shadow forest clearing hunter sparrow mountain cavern shelter"
  116. v.n2 = v.n2 "seagull lantern sunrise gecko welcome egret doorway water"
  117. v.n2 = v.n2 "prison temple valley spirit soldier blossom lotus maple"
  118. v.v1 = "walk write sing play look fail stray climb grow speak flow live"
  119. v.v1 = v.v1 "soar crawl creep stand wake sink swim turn sit jump stink"
  120. v.v1 = v.v1 "dive strive shine glow fade move crave spin hide writhe"
  121. v.v2 = "wander desire return whisper decline accept withdraw contend"
  122. v.v2 = v.v2 "rebel retire despair arise wither wonder bubble flutter grumble"
  123. v.v2 = v.v2 "enchant descend ascend command"
  124. v.p1 = "in near past through from"
  125. v.p2 = "under over behind beyond above below around"
  126. v.r1 = "where when while as"
  127. v.l1 = "the this my your his her the the the"
  128. v.h2 = "Gichin Koshi Raiko the_man a_maid Tanto the_queen Moki R.J. Gorby"
  129. v.h2 = v.h2 "Sanka the_monk Glad_Child Yoko"
  130. tem. = ""
  131. tem.1 = "A1 n1, a2 n1.+L1 a1, a2 n2 v1s.+A1 n1, a1 n2."
  132. tem.2 = "P2 the a1 n1,+R1 the a2 n2 v1s,+I v1; the n1 v1s."
  133. tem.3 = "The a1 n1 v1@;+It is the a2 n2.+V2@, I v1."
  134. tem.4 = "The a2 n1 v1s+R1 a2 n2s v2.+Does the a1 n1 v1?"
  135. tem.5 = "Not a1, not a2,+H2 comes to the n2.+L1 a1 n2 v1s."
  136. tem.6 = "A1, a2, a2,+H2 v1s. H2 v2s,+V2@, v1@."
  137. tem.7 = "/Never Always/ a1, but a1,+H2 knows /no all/ a1 n2s.+/Angry Gladdened/, /he she/ v1s."
  138. do i = 1 while tem.i ~= ""
  139. end
  140. num_templates = i-1
  141. return
  142.  
  143. /*
  144. **    EOF
  145. */
  146.